package com.example.PacMan;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;


public class PacmanGame extends JFrame {
    MyPanel mp = null;
    Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {

        new PacmanGame();
    }

    public PacmanGame(){
        System.out.println("Please select your choose 1: new game 2: continue");
        String key = scanner.next();
        mp = new MyPanel(key);

        Thread thread = new Thread(mp);
        thread.start();

        this.add(mp);
        this.setSize(1300,750);

        this.addKeyListener(mp);
        this.setTitle("Pac Man");

        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

        //when player closing the game, it will record current data
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                //Recorder.keepRecord01();
                Recorder.keepRecord02();
                System.exit(0);
            }
        });
    }


}

